package cn.itsource.config.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册拦截器
 */
@Configuration //声明是SpringMvc的配置
//WebMvcConfigurer 是 Web Mvc 配置器
public class registryDatabase implements WebMvcConfigurer {
//    注入拦截器
    @Autowired
    private LoginInterceptor interceptor;
    /**
     * 拦截--放行拦截器
     *
     */
    public void managingInterceptors(InterceptorRegistry registry){
//        管理拦截器
        registry.addInterceptor(interceptor)
                .addPathPatterns("/**") //拦截所有
                .excludePathPatterns("/**/login", "/shop/settlement", "/file/**"
                        , "/user/**","**/ShopRegister","/wechart/**")//放行
                .excludePathPatterns("/swagger-resources/**"
                        , "/webjars/**"
                        , "/v2/**"
                        , "/swagger-ui.html/**");//放行swagger

    }

}
